<div class="content fixed-fluid">
    <div class="row-fluid">
        <div class="main-content">
            <div class="mozaic-widget widget-timeline_stream_state_manager" data-guid="widget-156" data-initialized="true" >
                <div class="mozaic-widget widget-timeline" data-guid="widget-179" data-initialized="true" >
                    <div class="mentions tasks_annotables-mentions list-viewport">
                        <div style="padding: 20px">
                            <div class="searchBox">
                                <i class="seach-icon"></i>
                                <input id="doSearch" type="text" style="width: 200px"/>
                            </div>
                            <div class="search-content">
                                <script src="/Libs/datatables/media/js/jquery.dataTables.js"></script>
                                <link href="/CSS/Desktop/datatables.css" rel="stylesheet"/>
                                <script>
                                    $(document).ready(function() {
                                        $('#taskList').dataTable({
                                            "sPaginationType": "full_numbers",
                                            "aoColumnDefs": [
                                                {"bSortable": false, "aTargets": [0, 4]}
                                            ]
                                        });
                                        $('#doSearch').keyup(function() {
                                            $('#taskList_filter input').val($(this).val());
                                            $('#taskList_filter input').keyup();
                                        });
                                    });
                                </script>
                                <div id="managerTips" class="left-menu-tooltip fade bottom in" style="position: absolute; overflow: hidden; white-space: normal; display: none;">
                                    <div class="tooltip-arrow"></div>
                                    <div class="tooltip-inner">data</div>
                                </div>
                                <div id="tagSelector" class="" style="position: absolute; display: none;">
                                    <span class="square-hack"></span>
                                    <div class="dropdown-menu" style="display: block;">
                                        <ul class="overview">
                                            <?php
                                            $tags = Tag::getList();
                                            foreach ($tags as $tag) :
                                                ?>
                                                <li data-id="<?php echo $tag->tagId; ?>" class="plus">
                                                    <a class="action-color-active" title="<?php echo $tag->keywords ?>"><i class="icon-tag-list"></i><font><?php echo $tag->tagName; ?></font></a>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                </div>
                                <?php
                                $tagGroups = Tag::getGroups();
                                $tags = Tag::getTagsByGroup();
                                if (count($tagGroups) > 3) {
                                    ?>
                                    <div id="tagSelector" class="dropdown-menu" style="display: none;">
                                        <ul class="overview">
                                            <?php foreach ($tagGroups as $group) : ?>
                                                <li data-id="<?php echo $group['id']; ?>" class="email">
                                                    <a><font><?php echo $group['name']; ?></font></a>
                                                    <div class="dropdown-menu">
                                                        <ul class="overview sub-menu">
                                                            <?php
                                                            foreach ($tags as $tag) :
                                                                if ($tag->groupId != $group['id'])
                                                                    continue;
                                                                ?>
                                                                <li data-id="<?php echo $tag->tagId; ?>" class="plus">
                                                                    <a title="<?php echo $tag->keywords; ?>"><font><?php echo $tag->tagName; ?></font></a>
                                                                </li>
                                                            <?php endforeach; ?>
                                                        </ul>
                                                    </div>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>

                                <?php } else { ?>
                                    <div id="tagMenu" class="dropdown-menu" style="display: none;">
                                        <ul class="overview vertical">
                                            <?php foreach ($tagGroups as $group) : ?>                   
                                                <li>
                                                    <a><font><?php echo $group['name']; ?></font></a>
                                                    <ul class="overview sub-menu">
                                                        <?php
                                                        foreach ($tags as $tag) :
                                                            if ($tag->groupId != $group['id'])
                                                                continue;
                                                            ?>
                                                            <li data-id="<?php echo $tag->tagId; ?>" class="email">
                                                                <a title="<?php echo $tag->keywords; ?>"><font><?php echo $tag->tagName; ?></font></a>
                                                            </li>
                                                        <?php endforeach; ?>
                                                    </ul>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                <?php } ?>
                                <table id="taskList">
                                    <thead>
                                    <th width="2%"><input type="checkbox" name="checkAll"/></th>
                                    <th width="9%">Date</th>
                                    <th width="19%">Post</th>
                                    <th width="19%">Task Description</th>
                                    <th width="6%">Tags</th>
                                    <th width="10%">Department</th>
                                    <th widht="10%">Assigned To</th>
                                    <th width="19%">Action</th>
                                    <th width="6%">Done</th>
                                    </thead>
                                    <tbody>
                                        <?php
                                        if (count($this->taskView->tasks) > 0)
                                            foreach ($this->taskView->tasks as $task) :
                                                $fullContent = $task->post;
                                                ?>
                                                <tr>
                                                    <td><input type="checkbox" name="check[<?php echo $task->taskId; ?>]" taskid="<?php echo $task->taskId; ?>"/></td>
                                                    <td style="font-size: 0"><?php echo $task->taskDateCreated->format("U"); ?><a style="font-size: 13px"><?php echo $task->taskDateCreated->format("d M H:i"); ?></a></td>
                                                    <td><span><?php echo $fullContent; ?></span></td>
                                                    <td><span><?php echo $task->taskNote ?></span></td>
                                                    <td style="padding: 0"><div class="tags" taskid="<?php echo $task->taskId; ?>">
                                                            <?php
                                                            $tags = $task->tags;
                                                            foreach ($tags as $tag) {
                                                                $firstLetter = substr($tag->tagName, 0, 1);
                                                                echo '<span class="' . $firstLetter . '" title="' . $tag->tagName . '">' . $firstLetter . '</span>';
                                                            }
                                                            ?></div></td>
                                                    <td><?php echo $task->department; ?></td>
                                                    <td><?php echo $task->assignedTo->name ?></td>
                                                    <td><span><?php echo $task->action; ?></span></td>
                                                    <td style="font-size: 0; text-align: center;"><?php
                                                        switch ($task->taskType) {
                                                            case '10':
                                                                if ($task->status == 2) {
                                                                    echo 'done<i class="icon-share-indicator email complete"></i>';
                                                                } else {
                                                                    echo 'no<i taskid="' . $task->taskId . '" class="icon-share-indicator email notcomplete"></i><span style="font-size: 0; width: 0;">Send email now</span>';
                                                                }
                                                                break;
                                                            case '11':
                                                                if ($task->status == 2) {
                                                                    echo 'done<i class="icon-share-indicator sms complete"></i>';
                                                                } else {
                                                                    echo 'no<i taskid="' . $task->taskId . '" class="icon-share-indicator sms notcomplete"></i><span style="font-size: 0; width: 0;">Send SMS now</span>';
                                                                }
                                                                break;
                                                            default:
                                                                if ($task->status == 2)
                                                                    echo 'done<i class="done-icon complete"></i>';
                                                                else
                                                                    echo 'no<i taskid="' . $task->taskId . '" class="done-icon notcomplete"></i><span style="font-size: 0; width: 0;">Mark complete</span>';
                                                        }
                                                        ?></td>
                                                </tr>
                                            <?php endforeach; ?>
                                    </tbody>
                                </table>
                                <div class="action">
                                    <?php
                                    $type = strtoupper($_REQUEST['filter']);
                                    $buttonText = "";
                                    switch ($type) {
                                        case "TASKS":
                                            $buttonText = "Mark complete";
                                            break;
                                        case "EMAIL":
                                            $buttonText = "Send email";
                                            break;
                                        case "SMS":
                                            //$buttonText = "Send SMSes";
                                            break;
                                    }
                                    if ($buttonText != "") {
                                        echo "<button id=\"doWithAll\" class=\"btn btn-red commit\">$buttonText</button>";
                                    }
                                    ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>